﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Web_cuiki
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ReturnUrl"] != null)
                RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
            else
                RegisterUser.ContinueDestinationPageUrl = "Default.aspx";
        }
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
            Roles.AddUserToRole(RegisterUser.UserName,"user");
            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "~/";
            }
            KhachHangDAO.ThemKhachHang(RegisterUser.UserName, RegisterUser.UserName,RegisterUser.Password, "", "");
            Response.Redirect(continueUrl);
        }
    }
}